#import "TransitionScreen.h"
#import "State.h"
#import <QuartzCore/QuartzCore.h>
@implementation TransitionScreen
@synthesize player,lastStage,nextStage;

- (id)initWithFrame:(CGRect)frame {
    if ((self = [super initWithFrame:frame])) {
        state=S_TRANSITION;
		endTime=CACurrentMediaTime()+(64*0.15);
		x=0;
		self.image=[UIImage imageNamed:@"screen_transition.png"];
	}
	return self;
}

- (void) action:(int) x y:(int) y {
        state=S_PLAY;
 }
-(void)drawRect:(CGRect)rect{
	[super drawRect:rect];
    [lastStage drawAtPoint:CGPointMake(x,0)];
    [nextStage drawAtPoint:CGPointMake(x+320,0)];
	[self.image drawAtPoint:CGPointMake(x+160,0)];
 	if(player!=nil)
		[player paint];
}
- (int) stateMachine {
	x-=5;
	if(x<=-320){
		state=S_PLAY;
	}
	return state;
}

-(void) setTransition: (Stage*) stage{
	lastStage = stage.image;
	nextStage = [stage getNextStageImage];
	
}
@end
